package acm.蓝桥12;

import java.util.Scanner;

public class 满足的二进制位 {
    static long k;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        k = sc.nextLong();
        int res = 0;
        for (int i = 1; i <= n; i++) {
            if (check(i)) {
                res++;
            }
        }
        System.out.println(res);
    }

    public static boolean check(long x) {
        int res = 0;
        while (x != 0) {
            long cur=x & (-x);
            res++;
            x = cur ^ x;
        }
        return res == k;
    }
}
